﻿ function setRights()  
 {
    if((document.all.__funcid&&document.all.__funcid.value=="01010305")||appForm.ApplyState.value=="作废"||appForm.ApplyState.value=="已执行"||appForm.ApproveState.value=="已审批"||appForm.ApproveState.value=="审批中") deDisplay("save,saveclose"); 
    if((__mode.value=="2"||__mode.value=="3") && appForm.ApplyState.value!="作废")
    {
           var strReturn = GetDataFromXMLHTTP("/SLXT/XSXC/XSXC_XMLHTTP.aspx","GetProcessGUIDByContract",appForm.oid.value,"");
           if(strReturn!=undefined&&strReturn!="")
           { 
                var strIsHaveRight = GetDataFromXMLHTTP("/SLXT/XSXC/XSXC_XMLHTTP.aspx","IsHaveSpRight","01010305","10");
                if(strIsHaveRight=="1")
                {
                    document.all.txtWorkFlowGuid.value =strReturn;
                    reDisplay("WorkFlowsp,BtnWorkFlowspSpGc");
                }
           }
           else
           {    
                if(appForm.ApplyState.value!="已执行" &&appForm.ApproveState.value!="已审批")             
                {         
                   if(Form1.txtBgShConfig.value=="2")
                   {
                       var strIsHaveRight = "0";                         
                       var strFuncid="01010303";
                       if(appForm.SaleType.value=="合同")
                       {
                            strFuncid="01010304";
                       }
                                                           
                       strIsHaveRight = GetDataFromXMLHTTP("/SLXT/XSXC/XSXC_XMLHTTP.aspx","IsHaveSpRight",strFuncid,"16");                   
                       if(strIsHaveRight=="1")
                       {                      
                            reDisplay("WorkFlowsp,BtnWorkFlowspFq");
                       }                              
                   }            
                   else
                   {                   
                      var strIsHaveRight = GetDataFromXMLHTTP("/SLXT/XSXC/XSXC_XMLHTTP.aspx","IsHaveSpRight","01010305","10");
                      if(strIsHaveRight=="1")
                      {
                         reDisplay("sp");
                      }
                   }
               }                 
           }                          
    } 
    //如果该销售单已关闭，则隐藏保存，审批，发起审批按钮
    if(document.all.__Status&&document.all.__Status.value=="关闭")
    {
      
       if(document.all.BtnWorkFlowspSpGc.style.display=="none")
       {
           deDisplay("save,saveclose,sp,WorkFlowsp,BtnWorkFlowspFq");
       }
       else
       {
           deDisplay("save,saveclose,sp,BtnWorkFlowspFq");
       }
    }
}
//收集特批折扣变更xml
function getTpzkModiApplyXml() {
    var sDataXML = "";
    var SaleModiApplyGUID = appForm.oid.value;
    sDataXML += "<s_SaleModiApply keyname=\"SaleModiApplyGUID\" keyvalue='" + SaleModiApplyGUID + "'>";
    sDataXML += "<SaleGUID>" + appForm.SaleGUID.value + "</SaleGUID>";
    sDataXML += "<SaleType>" + appForm.SaleType.value + "</SaleType>";
    sDataXML += "<ApplyType>" + appForm.ApplyType.value + "</ApplyType>";
    sDataXML += "<ReasonSort>" + appForm.ReasonSort.value + "</ReasonSort>";
    sDataXML += "<Reason>" + appForm.Reason.value + "</Reason>";
    sDataXML += "<ApplyBy>" + appForm.ApplyBy.value + "</ApplyBy>";
    sDataXML += "<ApplyDate>" + appForm.ApplyDate.value + "</ApplyDate>";
    sDataXML += "<BUGUID>" + appForm.BUGUID.value + "</BUGUID>";
    sDataXML += "<ProjGUID>" + appForm.ProjGUID.value + "</ProjGUID>";
    sDataXML += "<RoomGUID>" + appForm.RoomGUID.value + "</RoomGUID>";
    sDataXML += "<CstName>" + appForm.CstName.value + "</CstName>";
    sDataXML += "<CstGUID>" + appForm.CstGUID.value + "</CstGUID>";
    sDataXML += "<IsApproved>" + appForm.IsApproved.value + "</IsApproved>";
    sDataXML += "<Pay>" + appForm.Pay.value + "</Pay>";
    sDataXML += "<HandCharge>" + appForm.HandCharge.value + "</HandCharge>";
    sDataXML += "<ApproveState>" + appForm.ApproveState.value + "</ApproveState>";
    sDataXML += "<ApplyState>" + appForm.ApplyState.value + "</ApplyState>";
    sDataXML += "</s_SaleModiApply>";

    sDataXML += "<s_SModiInfo keyname=\"SaleModiApplyGUID\" keyvalue='[SaleModiApplyGUID]'>";
    sDataXML += "<BldCjPrice>" + appForm.appForm_newBldCjPrice.value.replace(/,/g, "") +"</BldCjPrice>";
    sDataXML += "<TnCjPrice>" + appForm.appForm_newTnCjPrice.value.replace(/,/g, "") + "</TnCjPrice>";
    sDataXML += "<RoomTotal>" + appForm.appForm_newRoomTotal.value.replace(/,/g, "") + "</RoomTotal>";
    sDataXML += "<DjBldCjPrice>" + appForm.appForm_DjBldCjPrice.value.replace(/,/g, "") + "</DjBldCjPrice>";
    sDataXML += "<DjTnCjPrice>" + appForm.appForm_DjTnCjPrice.value.replace(/,/g, "") + "</DjTnCjPrice>";
    sDataXML += "<DjRoomTotal>" + appForm.appForm_DjRoomTotal.value.replace(/,/g, "") + "</DjRoomTotal>";
    sDataXML += "<ZxTotal>" + appForm.appForm_ZxTotal.value.replace(/,/g, "") + "</ZxTotal>";
    sDataXML += "<FsTotal>" + appForm.appForm_FsTotal.value.replace(/,/g, "") + "</FsTotal>";
    sDataXML += "<RmbCjTotal>" + appForm.appForm_RoomTotal.value.replace(/,/g, "") + "</RmbCjTotal>";
    sDataXML += "<OfferType>" + appForm.appForm_OfferType.value + "</OfferType>";
    sDataXML += "<OfferDiscntValue>" + appForm.appForm_OfferDiscntValue.value.replace(/,/g, "") + "</OfferDiscntValue>";
    sDataXML += "<OfferPrice>" + appForm.appForm_OfferPrice.value.replace(/,/g, "") + "</OfferPrice>";
    sDataXML += "<CalMode>" + appForm.appForm_CalMode.value + "</CalMode>";
    sDataXML += "<PayformName>" + appForm.appForm_PayformName.value + "</PayformName>";
    sDataXML += "<ZxBz>" + appForm.appForm_ZxBz.value + "</ZxBz>";
    sDataXML += "<ZxPrice>" + appForm.appForm_ZxPrice.value.replace(/,/g, "") + "</ZxPrice>";
    sDataXML += "<IsZxkbrht>" + appForm.appForm_IsZxkbrht.value.replace(/,/g, "") + "</IsZxkbrht>";
    sDataXML += "<Bz>" + appForm.appForm_Bz.value.replace(/,/g, "") + "</Bz>";
    sDataXML += "<ExRate>" + appForm.appForm_ExRate.value.replace(/,/g, "") + "</ExRate>";
    sDataXML += "<CjTotal>" + appForm.appForm_CjTotal.value.replace(/,/g, "") + "</CjTotal>";
    sDataXML += "</s_SModiInfo>";
    return sDataXML;
}

//收集未开启审批时，特批折扣变更xml
function getTpzkModiApplyXml_fsp() {
    var sDataXML = "";
    var SaleModiApplyGUID = appForm.oid.value;
    sDataXML += "<s_SaleModiApply keyname=\"SaleModiApplyGUID\" keyvalue='" + SaleModiApplyGUID + "'>";
    sDataXML += "<SaleGUID>" + appForm.SaleGUID.value + "</SaleGUID>";
    sDataXML += "<SaleType>" + appForm.SaleType.value + "</SaleType>";
    sDataXML += "<ApplyType>" + appForm.ApplyType.value + "</ApplyType>";
    sDataXML += "<ReasonSort>" + appForm.ReasonSort.value + "</ReasonSort>";
    sDataXML += "<Reason>" + appForm.Reason.value + "</Reason>";
    sDataXML += "<ApplyBy>" + appForm.ApplyBy.value + "</ApplyBy>";
    sDataXML += "<ApplyDate>" + appForm.ApplyDate.value + "</ApplyDate>";
    sDataXML += "<BUGUID>" + appForm.BUGUID.value + "</BUGUID>";
    sDataXML += "<ProjGUID>" + appForm.ProjGUID.value + "</ProjGUID>";
    sDataXML += "<RoomGUID>" + appForm.RoomGUID.value + "</RoomGUID>";
    sDataXML += "<CstName>" + appForm.CstName.value + "</CstName>";
    sDataXML += "<CstGUID>" + appForm.CstGUID.value + "</CstGUID>";
    sDataXML += "<IsApproved>" + appForm.appForm_IsApproved.value + "</IsApproved>";
    sDataXML += "<Pay>" + appForm.Pay.value + "</Pay>";
    sDataXML += "<Opinion>" + appForm.Opinion.value + "</Opinion>";
    sDataXML += "<ApproveBy>" + appForm.ApproveBy.value + "</ApproveBy>";
    sDataXML += "<ApproveDate>" + appForm.ApproveDate.value + "</ApproveDate>";
    sDataXML += "<ApplyState></ApplyState>";
    sDataXML += "<ApproveState>已审批</ApproveState>";
    sDataXML += "</s_SaleModiApply>";

    sDataXML += "<s_SModiInfo keyname=\"SaleModiApplyGUID\" keyvalue='[SaleModiApplyGUID]'>";
    sDataXML += "<BldCjPrice>" + appForm.appForm_newBldCjPrice.value.replace(/,/g, "") + "</BldCjPrice>";
    sDataXML += "<TnCjPrice>" + appForm.appForm_newTnCjPrice.value.replace(/,/g, "") + "</TnCjPrice>";
    sDataXML += "<RoomTotal>" + appForm.appForm_newRoomTotal.value.replace(/,/g, "") + "</RoomTotal>";
    sDataXML += "<DjBldCjPrice>" + appForm.appForm_DjBldCjPrice.value.replace(/,/g, "") + "</DjBldCjPrice>";
    sDataXML += "<DjTnCjPrice>" + appForm.appForm_DjTnCjPrice.value.replace(/,/g, "") + "</DjTnCjPrice>";
    sDataXML += "<DjRoomTotal>" + appForm.appForm_DjRoomTotal.value.replace(/,/g, "") + "</DjRoomTotal>";
    sDataXML += "<ZxTotal>" + appForm.appForm_ZxTotal.value.replace(/,/g, "") + "</ZxTotal>";
    sDataXML += "<FsTotal>" + appForm.appForm_FsTotal.value.replace(/,/g, "") + "</FsTotal>";
    sDataXML += "<RmbCjTotal>" + appForm.appForm_RoomTotal.value.replace(/,/g, "") + "</RmbCjTotal>";
    sDataXML += "<OfferType>" + appForm.appForm_OfferType.value + "</OfferType>";
    sDataXML += "<OfferDiscntValue>" + appForm.appForm_OfferDiscntValue.value.replace(/,/g, "") + "</OfferDiscntValue>";
    sDataXML += "<OfferPrice>" + appForm.appForm_OfferPrice.value.replace(/,/g, "") + "</OfferPrice>";
    sDataXML += "<CalMode>" + appForm.appForm_CalMode.value + "</CalMode>";
    sDataXML += "<PayformName>" + appForm.appForm_PayformName.value + "</PayformName>";
    sDataXML += "<ZxBz>" + appForm.appForm_ZxBz.value + "</ZxBz>";
    sDataXML += "<ZxPrice>" + appForm.appForm_ZxPrice.value.replace(/,/g, "") + "</ZxPrice>";
    sDataXML += "<IsZxkbrht>" + appForm.appForm_IsZxkbrht.value.replace(/,/g, "") + "</IsZxkbrht>";
    sDataXML += "<Bz>" + appForm.appForm_Bz.value.replace(/,/g, "") + "</Bz>";
    sDataXML += "<ExRate>" + appForm.appForm_ExRate.value.replace(/,/g, "") + "</ExRate>";
    sDataXML += "<CjTotal>" + appForm.appForm_CjTotal.value.replace(/,/g, "") + "</CjTotal>";
    sDataXML += "</s_SModiInfo>";

    return sDataXML;
}